//
//  ActivityNetService.m
//  Shengzhuli
//
//  Created by FXGuo on 2017/4/12.
//  Copyright © 2017年 kamangkeji. All rights reserved.
//

#import "ActivityNetService.h"
#import "GFXNetworkHandle.h"
#import "ActivityModel.h"
#import "InfomationModel.h"
#import "BannerModel.h"

NSString * const ActivityUrl = @"activity/list";//活动列表
NSString * const ActivityDetail = @"app/html/activityDetail";//活动详情

NSString * const InformationList = @"information/listpage";//资讯列表
NSString * const InformationDetail = @"information/detail";//资讯详情
NSString * const InfoBanner = @"information/bannerList";//资讯banner


@implementation ActivityNetService

+ (void)getActivityListsWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:ActivityUrl params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                ActivityModel *model = [ActivityModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getActivityDetailWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]get:ActivityDetail params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"],nil);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getInformationListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:InformationList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *lists = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                InfomationModel *model = [InfomationModel objectWithDict:dict];
                [lists addObject:model];
            }
            response(YES,json[@"message"],lists);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getInformationDetailWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSString *detailStr))response
{
    [[GFXNetworkHandle shareHandle]post:InformationDetail params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            response(YES,json[@"message"],json[@"result"]);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getInfoBannerListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *banners))response
{
    [[GFXNetworkHandle shareHandle]post:InfoBanner params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *banners = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                BannerModel *model = [BannerModel bannerWithDict:dict];
                [banners addObject:model];
            }
            response(YES,json[@"message"],banners);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

@end
